<?php
/**
 * Created by PhpStorm.
 * User: xzw
 * Date: 2018/8/1
 * Time: 18:10
 */
header("Access-Control-Allow-Origin:*");
header("Content-Type:application/json;charset=utf-8");
include "config.php";
if($_SERVER["REQUEST_METHOD"]=="POST"){
    $phoneNumber = $_REQUEST["phoneNumber"];
    $pwd = $_REQUEST["pwd"];
    if(!empty($phoneNumber)&&!empty($pwd )) {
        $querySql = "SELECT * FROM zols WHERE phoneNumber = ? AND PASSWORD =?";
        //2.预处理
        $stmt = $conn->prepare($querySql);
        $stmt->bind_param("ss", $phoneNumber,$pwd);
        $stmt->execute();
        $result = $stmt->get_result();
        if ($result->num_rows >= 1) {
            //存在就返回fasle
            print_r(json_encode(array("status" => 1, "msg" => "登录成功")));
        } else {
            print_r(json_encode(array("status" => 0, "msg" => "用户名或密码错误")));
            //不存在就返回true
        }
    }
    else{
        print_r(json_encode(array("status" => -1, "msg" => "用户名和密码不能为空")));
    }
}

